home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char rcsid[] =
- "@(#) $Header: /src/X11/contrib/demos/xphoon/RCS/fullmoon.c,v 1.5 90/06/27 10:29:59 tim Exp $ (LBL)";
- #endif
-
- /*
- ** Copyright (C) 1988 by Jef Poskanzer and Craig Leres.
- **
- ** Permission to use, copy, modify, and distribute this software and its
- ** documentation for any purpose and without fee is hereby granted, provided
- ** that the above copyright notice appear in all copies and that both that
- ** copyright notice and this permission notice appear in supporting
- ** documentation. This software is provided "as is" without express or
- ** implied warranty.
- */
-
- #include <X11/Xlib.h>
- #include <bigfullmoon.xbm>
- #define CENTER_X 800
- #define CENTER_Y 645
- #define RADIUS 378
-
- checkbitmapsize(w, h)
- int *w, *h;
- {
- int minw, minh;
- minw = ((CENTER_X + RADIUS + 7)/8 - (CENTER_X - RADIUS)/8) * 8;
- minh = 2*RADIUS;
- if (*w < minw) *w = minw;
- if (*h < minh) *h = minh;
- if (*w > bigfullmoon_width) *w = bigfullmoon_width;
- if (*h > bigfullmoon_height) *h = bigfullmoon_height;
- }
-
- getbitmap(w, h, bits, cx, cy, r)
- int w, h;
- char *bits;
- int *cx, *cy, *r;
- {
- int bx, by; /* origin of fullmoon bitmap in display coordinates */
- int fl, dl; /* length of scan line in bytes of fullmoon, display */
- int fb; /* useable bytes of image */
- int y; /* Current position in display bitmap */
- char *fbp, *dbp; /* Pointers to current bitmap position */
-
- dl = (w+7)/8;
- fl = (bigfullmoon_width+7)/8;
- fb = (bigfullmoon_width)/8;
-
- bx = (dl-fb)/2;
- by = (h-bigfullmoon_height)/2;
- if (h < 900) by -= 5; /* center fullmoon vertically */
-
- *cx = CENTER_X+bx*8;
- *cy = CENTER_Y+by;
- *r = RADIUS;
-
- dbp = bits;
- for (y=0; y<h; y++){
- fbp = bigfullmoon_bits + (y-by)*fl - bx;
- bcopy(fbp,dbp,dl);
- dbp += dl;
- }
- }
-